using System;

/// <summary>
/// Summary description for Class1
/// </summary>
public class URLNormalizer
{

    string day = string.Empty;
    string year = string.Empty;
    string month = string.Empty;
    string shortYear = string.Empty;
    string url = string.Empty;
    string fname = string.Empty;

    public URLNormalizer()
	{
		//
		// TODO: Add constructor logic here
		//
	}

    public void normalize(string urlString, string date){
        day = date.Substring(0, 2);
        month = date.Substring(3, 2);
        year = date.Substring(6, 4);
        shortYear = date.Substring(8, 2);
        urlString = urlString.Replace("{day}", day);
        urlString = urlString.Replace("{year}", year);
        urlString = urlString.Replace("{month}", month);
        urlString = urlString.Replace("{shortYear}", shortYear);
        url = urlString;
        fname = string.Empty;
        //return urlString;
    }

    public string NormalizedURL() {
        return url;
    }

    public string filename(){
        if (fname == string.Empty)
        {
            int start = url.LastIndexOf('/');
            if (start == -1) return null; else start += 1;
            int end = url.Length - start;
            fname = url.Substring(start, end);
            return fname;
        }return fname;
    }

    public void setFilename(string file) {
        fname = file;
    }
}
